/*
 * @Description: 4.表单常规单元组件 item—normalCell (INC1)
 * @Author: skj
 * @Date: 2019-08-29 11:15:45
 * @LastEditors: skj
 * @LastEditTime: 2019-08-30 13:04:38
 */
import React, { Component } from "react";
import { View, StyleSheet, Text, ViewPropTypes, Image } from "react-native";
import PropTypes from "prop-types";
import Button from "react-native-elements/src/buttons/Button";
import Line from "../item-line/index";

export default class ItemButtonView extends Component {
    render() {
        const {
            title,
            titleStyle,
            onPress,
            showBottomLine,
            speratorLineStyle,
            buttonTitle,
            buttonStyle,
            buttonTitleStyle,
            disabled,
            disabledTitleStyle,
            disabledStyle,
            showAccessoryBtn,
            containerStyle
        } = this.props;
        return (
            <View style={[styles.container,containerStyle]}>
                <View style={styles.content_style}>
                    <Text style={[styles.titleStyle, titleStyle]} numberOfLines={1} includeFontPadding={false}>
                        {title}
                    </Text>
                    {showAccessoryBtn && (
                        <Button
                            title={buttonTitle}
                            titleStyle={[styles.buttonTitleStyle, buttonTitleStyle]}
                            buttonStyle={[styles.buttonStyle, buttonStyle]}
                            type="outline"
                            onPress={onPress}
                            disabled={disabled}
                            disabledStyle={[styles.disabledStyle, disabledStyle]}
                            disabledTitleStyle={[styles.disabledTitleStyle, disabledTitleStyle]}
                        />
                    )}
                </View>
                {showBottomLine && <Line style={[{ marginLeft: 0 }, speratorLineStyle]} />}
            </View>
        );
    }
}
ItemButtonView.propTypes = {
    title: PropTypes.string, //标题
    titleStyle: PropTypes.oneOfType([Text.propTypes.style,ViewPropTypes.style]),
    containerStyle:ViewPropTypes.style,
    buttonTitle:PropTypes.string,
    buttonStyle: ViewPropTypes.style,
    buttonTitleStyle: Text.propTypes.style,
    disabled: PropTypes.bool,
    disabledStyle: ViewPropTypes.style,
    disabledTitleStyle: Text.propTypes.style,
    onPress: PropTypes.func,
    showBottomLine: PropTypes.bool,
    showAccessoryBtn: PropTypes.bool,
    speratorLineStyle: ViewPropTypes.style
};
ItemButtonView.defaultProps = {
    title: "标题",
    buttonTitle:"补全资料",
    showBottomLine: true,
    disabled: false,
    showAccessoryBtn: true
};
const styles = StyleSheet.create({
    container: {
        height: 40,
        backgroundColor: "#ffffff"
    },
    content_style: {
        alignItems: "center",
        flexDirection: "row",
        flex: 1
    },
    titleStyle: {
        color: "#444444",
        fontSize: 15,
        marginLeft: 15,
        marginRight: 10,
        flex: 1
    },
    buttonTitleStyle: {
        fontSize: 12,
        color: "#E83C36",
        paddingTop: 0,
        paddingBottom: 0
    },
    buttonStyle: {
        backgroundColor: "#fff",
        borderColor: "#E83C36",
        borderWidth: 1,
        borderRadius: 3,
        paddingTop: 7,
        paddingBottom: 6,
        paddingLeft: 6,
        paddingRight: 6,
        marginRight: 15
    },
    disabledStyle: {
        borderColor: "#999999"
    },
    disabledTitleStyle: {
        color: "#999999"
    }
});
